from django.shortcuts import render
from .models import Circular
import mistune

# Create your views here.
def circular_detail(request,id):
    """通知详情页"""
    # 取出相应的通知
    circular = Circular.objects.get(id=id)
    # 增加阅读数
    circular.click_count += 1
    circular.save(update_fields=['click_count'])
    #前台mK解析
    mk = mistune.Markdown()
    output = mk(circular.content)
    # 需要传递给模板的对象
    context = {
        'circular': circular,
        'circular_detail_html': output,
    }
    # 载入模板，并返回context对象
    return render(request,'circular/circular_detail.html',context)